﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;


namespace LedDemo
{
    class LedControl
    {
        public const int JR_OK = 0;

        public const int DEV_TCP        = 0;
        public const int DEV_UDP        = 1;
        public const int DEV_PCAP       = 2;
        public const int DEV_SERIALPORT = 3;

        public const int DEV_COMM = DEV_UDP;

        public const string zkdll = "..\\..\\..\\..\\Dll\\windows\\jinhanzk.dll";
        public const string commdll = "..\\..\\..\\..\\Dll\\windows\\jinhancomm.dll";

        [StructLayout(LayoutKind.Sequential, Pack = 1)]
        public struct JHLEDMODULE    //扫描
        {
            public byte lmScanDirection;//扫描方向,0x00：正常；0x01：镜像
            public byte lmColor;//显示屏颜色,0x00：单色；0x01：双色；0x02：彩色；0x03：虚拟彩色色；
            public byte lmScan;//扫描,1/16 扫描，该值为 0x10
            public byte lmOSR;//每区扫描行数
            public byte lmOSC;//每区扫描列数
            public byte lmRowDecode;//行译码,0x00：138 译码；0x01：ABCD 直译；
            public byte lmPolar;//极性设置
            public byte lmClockPhase;//时钟相位，保留，始终为 0
            public byte lmLatchPhase;//锁存相位；保留，始终为 0
            public byte lmData;//数据组织，如 RGB，BGR；保留，始终为 0
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
            public byte[] lmReserve;//保留，始终为 0
            public ushort lmTrackMode;//走线路径(track)(方向均以正常放置的单元板的正面为视角)
            public ushort lmTrackSize;//扫描路径大小
        };

        public struct JHSYSTEMTIME
        {
            public ushort wYear;
            public ushort wMonth;
            public ushort wDayOfWeek;
            public ushort wDay;
            public ushort wHour;
            public ushort wMinute;
            public ushort wSecond;
            public ushort wMilliseconds;
        };

        public struct JHLOGFONT
        {
	        public uint   lfHeight;
	        public uint   lfWidth;
	        public uint   lfEscapement;
	        public uint   lfOrientation;
	        public uint   lfWeight;
	        public byte   lfItalic;
	        public byte   lfUnderline;
	        public byte   lfStrikeOut;
	        public byte   lfCharSet;
	        public byte   lfOutPrecision;
	        public byte   lfClipPrecision;
	        public byte   lfQuality;
	        public byte   lfPitchAndFamily;
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
	        public byte[] lfFaceName;
        };

        public struct JHBMPSRC
        {
	        public ushort type;
	        public ushort version;
	        public uint  size;
            public byte[] pdata;
        };

        public struct JHBMPINFO
        {
            public ushort type;
            public ushort version;
            public uint size;
        };

        public struct JHTEXTPROG
        {
	        public ushort  tpEntryMode;
	        public ushort  tpEntrySpeed;
	        public ushort  tpEntryStaytime;
	        public ushort  tpHighLightMode;
	        public ushort  tpHighLightSpeed;
	        public ushort  tpHighLightStaytime;
	        public ushort  tpExitMode;
	        public ushort  tpExitSpeed;
	        public ushort  tpRepeatTimes;
        };

        public struct BITMAPINFOHEADER
        {
            public uint biSize;
            public uint biWidth;
            public uint biHeight;
            public ushort biPlanes;
            public ushort biBitCount;
            public uint biCompression;
            public uint biSizeImage;
            public uint biXPelsPerMeter;
            public uint biYPelsPerMeter;
            public uint biClrUsed;
            public uint biClrImportant;
        };

        [DllImport(commdll, EntryPoint = "JHCommInit", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHCommInit();

        [DllImport(commdll, EntryPoint = "JHCommDeinit", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHCommDeinit();

        [DllImport(commdll, EntryPoint = "JHCommGetTransportlayer", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHCommGetTransportlayer(ref IntPtr ptransportlayer, int dev);

        [DllImport(commdll, EntryPoint = "JHCommReleaseArgStruct", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHCommReleaseArgStruct(IntPtr pargs);

        [DllImport(commdll, EntryPoint = "JHCommGetNetArgStruct", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHCommGetNetArgStruct(ref IntPtr pargs, string ipordomain, ushort port, uint timeout);

        [DllImport(commdll, EntryPoint = "JHCommGetEtherArgStruct", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHCommGetEtherArgStruct(ref IntPtr pargs, string source, byte[] mac, uint timeout);

        [DllImport(commdll, EntryPoint = "JHCommGetSerialportArgStruct", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHCommGetSerialportArgStruct(ref IntPtr pargs, string name, uint baudrate, byte databits, byte parity, byte stopbits, uint timeout);

        [DllImport(zkdll, EntryPoint = "JHCreateInst", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHCreateInst(ref IntPtr hdl, ushort serverid);

        [DllImport(zkdll, EntryPoint = "JHDeleteInst", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHDeleteInst(IntPtr hdl);

        [DllImport(zkdll, EntryPoint = "JHMountTransportLayer", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHMountTransportLayer(IntPtr hdl, IntPtr ptl, IntPtr argstruct);
        
        /***************************************系统指令开始*********************************/

        [DllImport(zkdll, EntryPoint = "JHChangeInstServerId", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHChangeInstServerId(IntPtr hdl, ushort serverid);

        [DllImport(zkdll, EntryPoint = "JHChangeInstRelativeId", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHChangeInstRelativeId(IntPtr hdl, ushort serverid);
        
        [DllImport(zkdll, EntryPoint = "JHGetGID", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGetGID(IntPtr hdl, ref ushort pgid);

        [DllImport(zkdll, EntryPoint = "JHSetGID", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHSetGID(IntPtr hdl, ushort gid);

        [DllImport(zkdll, EntryPoint = "JHGetUID", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGetUID(IntPtr hdl, byte[] uid);

        [DllImport(zkdll, EntryPoint = "JHGetGIDByUID", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGetGIDByUID(IntPtr hdl, byte[] uid, ref ushort pgid);

        [DllImport(zkdll, EntryPoint = "JHSetGIDByUID", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHSetGIDByUID(IntPtr hdl, byte[] uid, ushort pgid);

        [DllImport(zkdll, EntryPoint = "JHGetSerialAttr", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGetSerialAttr(IntPtr hdl, ref uint pbaudrate, ref byte pdatabits, ref byte pparity, ref byte pstopbits, ref byte pflowctrl);

        [DllImport(zkdll, EntryPoint = "JHSetSerialAttr", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHSetSerialAttr(IntPtr hdl, uint pbaudrate, byte pdatabits, byte pparity, byte pstopbits, byte pflowctrl);

        [DllImport(zkdll, EntryPoint = "JHGetPort", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGetPort(IntPtr hdl, ref ushort pport);

        [DllImport(zkdll, EntryPoint = "JHSetPort", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHSetPort(IntPtr hdl, ushort pport);

        [DllImport(zkdll, EntryPoint = "JHGetIPv4", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGetIPv4(IntPtr hdl, ref uint pipctrl, ref uint pipv4, ref uint pnetmask, ref uint pdefgw, ref uint ppridns, ref uint psecdns);

        [DllImport(zkdll, EntryPoint = "JHSetIPv4", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHSetIPv4(IntPtr hdl, uint pipctrl, uint pipv4, uint pnetmask, uint pdefgw, uint ppridns, uint psecdns);

        [DllImport(zkdll, EntryPoint = "JHGetMac", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGetMac(IntPtr hdl, byte[] mac);

        [DllImport(zkdll, EntryPoint = "JHGetLedSize", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGetLedSize(IntPtr hdl, ref ushort pwidth, ref ushort pheight);

        [DllImport(zkdll, EntryPoint = "JHSetLedSize", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHSetLedSize(IntPtr hdl, ushort pwidth, ushort pheight);

        [DllImport(zkdll, EntryPoint = "JHGetDefLedMod", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGetDefLedMod(IntPtr hdl, ref JHLEDMODULE pledmodule, byte[] ptrack);

        [DllImport(zkdll, EntryPoint = "JHSetDefLedMod", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHSetDefLedMod(IntPtr hdl, ref JHLEDMODULE pledmodule, byte[] ptrack);

        [DllImport(zkdll, EntryPoint = "JHGetCurLedMod", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGetCurLedMod(IntPtr hdl, ref JHLEDMODULE pledmodule, byte[] ptrack);

        [DllImport(zkdll, EntryPoint = "JHSetCurLedMod", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHSetCurLedMod(IntPtr hdl, ref JHLEDMODULE pledmodule, byte[] ptrack);

        [DllImport(zkdll, EntryPoint = "JHGetDefRefreq", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGetDefRefreq(IntPtr hdl, ref ushort prefreq);

        [DllImport(zkdll, EntryPoint = "JHSetDefRefreq", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHSetDefRefreq(IntPtr hdl, ushort refreq);

        [DllImport(zkdll, EntryPoint = "JHGetDefLum", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGetDefLum(IntPtr hdl, ref ushort plum);

        [DllImport(zkdll, EntryPoint = "JHSetDefLum", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHSetDefLum(IntPtr hdl, ushort lum);

        [DllImport(zkdll, EntryPoint = "JHGetCurLum", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGetCurLum(IntPtr hdl, ref ushort plum);

        [DllImport(zkdll, EntryPoint = "JHSetCurLum", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHSetCurLum(IntPtr hdl, ushort lum);

        [DllImport(zkdll, EntryPoint = "JHGetDefFont", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGetDefFont(IntPtr hdl, ref byte pfid);

        [DllImport(zkdll, EntryPoint = "JHSetDefFont", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHSetDefFont(IntPtr hdl, byte fid);

        [DllImport(zkdll, EntryPoint = "JHGetCurFont", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGetCurFont(IntPtr hdl, ref byte pfid);

        [DllImport(zkdll, EntryPoint = "JHSetCurFont", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHSetCurFont(IntPtr hdl, byte fid);

        [DllImport(zkdll, EntryPoint = "JHGetDefPenColor", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGetDefPenColor(IntPtr hdl, ref uint pcolor);

        [DllImport(zkdll, EntryPoint = "JHSetDefPenColor", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHSetDefPenColor(IntPtr hdl, uint color);

        [DllImport(zkdll, EntryPoint = "JHGetCurPenColor", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGetCurPenColor(IntPtr hdl, ref uint pcolor);

        [DllImport(zkdll, EntryPoint = "JHSetCurPenColor", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHSetCurPenColor(IntPtr hdl, uint color);

        [DllImport(zkdll, EntryPoint = "JHGetDefBrushColor", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGetDefBrushColor(IntPtr hdl, ref uint pcolor);

        [DllImport(zkdll, EntryPoint = "JHSetDefBrushColor", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHSetDefBrushColor(IntPtr hdl, uint color);

        [DllImport(zkdll, EntryPoint = "JHGetCurBrushColor", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGetCurBrushColor(IntPtr hdl, ref uint pcolor);

        [DllImport(zkdll, EntryPoint = "JHSetCurBrushColor", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHSetCurBrushColor(IntPtr hdl, uint color);

        [DllImport(zkdll, EntryPoint = "JHGetLocale", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGetLocale(IntPtr hdl, ref ushort plocale);

        [DllImport(zkdll, EntryPoint = "JHGetSystemTime", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGetSystemTime(IntPtr hdl, ref JHSYSTEMTIME ptime);

        [DllImport(zkdll, EntryPoint = "JHSetSystemTime", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHSetSystemTime(IntPtr hdl, ref JHSYSTEMTIME time);

        [DllImport(zkdll, EntryPoint = "JHGetSystemVersion", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGetSystemVersion(IntPtr hdl, ref uint phwver, ref uint pswver);

        [DllImport(zkdll, EntryPoint = "JHGetRestCapacity", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGetRestCapacity(IntPtr hdl, ref uint pcapacity);

        [DllImport(zkdll, EntryPoint = "JHGetTotalCapacity", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGetTotalCapacity(IntPtr hdl, ref uint pcapacity);

        [DllImport(zkdll, EntryPoint = "JHGetSilentMode", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGetSilentMode(IntPtr hdl, ref byte psilentmode);

        [DllImport(zkdll, EntryPoint = "JHSetSilentMode", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHSetSilentMode(IntPtr hdl, byte psilentmode);

        [DllImport(zkdll, EntryPoint = "JHPower", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHPower(IntPtr hdl, byte onoff);

        [DllImport(zkdll, EntryPoint = "JHRestart", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHRestart(IntPtr hdl);

        [DllImport(zkdll, EntryPoint = "JHPreUpgrade", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHPreUpgrade(IntPtr hdl, ref IntPtr fd, uint writesize);

        [DllImport(zkdll, EntryPoint = "JHWriteUpgrade", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHWriteUpgrade(IntPtr hdl, IntPtr fd, uint woffset, byte[] pdata, uint size);

        [DllImport(zkdll, EntryPoint = "JHFinUpgrade", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHFinUpgrade(IntPtr hdl, IntPtr fd);

        [DllImport(zkdll, EntryPoint = "JHRestoreFactory", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHRestoreFactory(IntPtr hdl);

        [DllImport(zkdll, EntryPoint = "JHRestoreSysFactory", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHRestoreSysFactory(IntPtr hdl);

        /***************************************系统指令结束*********************************/


        /***************************************字库指令开始*********************************/

        [DllImport(zkdll, EntryPoint = "JHGetFontCnt", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGetFontCnt(IntPtr hdl, ref byte pcnt);

        [DllImport(zkdll, EntryPoint = "JHGetFontId", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGetFontId(IntPtr hdl, byte index, ref byte pfid);

        [DllImport(zkdll, EntryPoint = "JHGetFontInfo", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGetFontInfo(IntPtr hdl, byte fid, ref JHLOGFONT plogfont);

        [DllImport(zkdll, EntryPoint = "JHInquireFont", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHInquireFont(IntPtr hdl, byte fid);

        [DllImport(zkdll, EntryPoint = "JHPreCreateFont", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHPreCreateFont(IntPtr hdl, ref IntPtr fd, byte fid, uint writesize);

        [DllImport(zkdll, EntryPoint = "JHWriteFont", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHWriteFont(IntPtr hdl, IntPtr fd, uint woffset, byte[] pdata, uint size);

        [DllImport(zkdll, EntryPoint = "JHFinCreateFont", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHFinCreateFont(IntPtr hdl, IntPtr fd);

        [DllImport(zkdll, EntryPoint = "JHDeleteFont", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHDeleteFont(IntPtr hdl, byte fid);

        /***************************************字库指令结束*********************************/


        /***************************************屏幕操作指令开始*********************************/

        [DllImport(zkdll, EntryPoint = "JHErase", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHErase(IntPtr hdl);

        [DllImport(zkdll, EntryPoint = "JHDrawMultPixel", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHDrawMultPixel(IntPtr hdl, ushort[] pdat, ushort poscnt);

        [DllImport(zkdll, EntryPoint = "JHDrawMultPixelEx", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHDrawMultPixelEx(IntPtr hdl, ushort[] pdat, ushort poscnt, uint color);

        [DllImport(zkdll, EntryPoint = "JHDrawLine", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHDrawLine(IntPtr hdl, short x1, short y1, short x2, short y2);

        [DllImport(zkdll, EntryPoint = "JHDrawLineEx", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHDrawLineEx(IntPtr hdl, short x1, short y1, short x2, short y2, uint color);

        [DllImport(zkdll, EntryPoint = "JHFrameRect", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHFrameRect(IntPtr hdl, short x, short y, ushort width, ushort height);

        [DllImport(zkdll, EntryPoint = "JHFrameRectEx", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHFrameRectEx(IntPtr hdl, short x, short y, ushort width, ushort height, uint color);

        [DllImport(zkdll, EntryPoint = "JHFillRect", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHFillRect(IntPtr hdl, short x, short y, ushort width, ushort height);

        [DllImport(zkdll, EntryPoint = "JHFillRectEx", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHFillRectEx(IntPtr hdl, short x, short y, ushort width, ushort height, uint color);

        [DllImport(zkdll, EntryPoint = "JHDrawText", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHDrawText(IntPtr hdl, short x, short y, ushort width, ushort height, uint format, string ptext);

        [DllImport(zkdll, EntryPoint = "JHDrawBitmap", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHDrawBitmap(IntPtr hdl, short x, short y, ushort width, ushort height, uint format, ref JHBMPSRC pbmpsrc);

        [DllImport(zkdll, EntryPoint = "JHDrawMemBitmap", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHDrawMemBitmap(IntPtr hdl, short x, short y, ushort width, ushort height, uint format, ref JHBMPINFO pbmpinfo, byte[] pformatstring, byte is1bit);

        [DllImport(zkdll, EntryPoint = "JHDrawQRCode", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHDrawQRCode(IntPtr hdl, short x, short y, ushort width, ushort height, uint format, ref JHBMPINFO pbmpinfo, string pformatstring);

        [DllImport(zkdll, EntryPoint = "JHScrollLeft", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHScrollLeft(IntPtr hdl, short x, short y, ushort width, ushort height);

        [DllImport(zkdll, EntryPoint = "JHScrollRight", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHScrollRight(IntPtr hdl, short x, short y, ushort width, ushort height);

        [DllImport(zkdll, EntryPoint = "JHScrollUp", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHScrollUp(IntPtr hdl, short x, short y, ushort width, ushort height);

        [DllImport(zkdll, EntryPoint = "JHScrollDown", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHScrollDown(IntPtr hdl, short x, short y, ushort width, ushort height);

        /***************************************屏幕操作指令结束*********************************/




        /***************************************分区操作指令开始*********************************/

        [DllImport(zkdll, EntryPoint = "JHGetWndCnt", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGetWndCnt(IntPtr hdl, ref ushort pcnt);

        [DllImport(zkdll, EntryPoint = "JHGetWndId", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGetWndId(IntPtr hdl, ushort index, ref ushort wid);

        [DllImport(zkdll, EntryPoint = "JHFingerWnd", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHFingerWnd(IntPtr hdl, ushort wid, ref ushort px, ref ushort py, ref ushort pwidth, ref ushort pheight, ref uint pstyle, ref uint puserdata);

        [DllImport(zkdll, EntryPoint = "JHCreateWnd", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHCreateWnd(IntPtr hdl, ushort wid, ushort option, ushort x, ushort y, ushort width, ushort height, uint style, uint userdata);

        [DllImport(zkdll, EntryPoint = "JHChangeWnd", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHChangeWnd(IntPtr hdl, ushort wid, ushort x, ushort y, ushort width, ushort height, uint style, uint userdata);

        [DllImport(zkdll, EntryPoint = "JHDeleteWnd", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHDeleteWnd(IntPtr hdl, ushort wid);

        [DllImport(zkdll, EntryPoint = "JHWndPlayCtrl", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHWndPlayCtrl(IntPtr hdl, ushort wid, byte stat);

        [DllImport(zkdll, EntryPoint = "JHGetProgress", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGetProgress(IntPtr hdl, ushort wid, ref uint cur, ref uint ttl);

        [DllImport(zkdll, EntryPoint = "JHCreateTextProg", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHCreateTextProg(IntPtr hdl, ushort wid, ushort rev, uint style, uint format, ref JHTEXTPROG ptextprog, string pformatstring);

        [DllImport(zkdll, EntryPoint = "JHCreateBitmapProg", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHCreateBitmapProg(IntPtr hdl, ushort wid, ushort rev, uint style, uint format, ref JHTEXTPROG ptextprog, ushort rev2, ref JHBMPSRC pbmpsrc);

        [DllImport(zkdll, EntryPoint = "JHCreateMemBitmapProg", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHCreateMemBitmapProg(IntPtr hdl, ushort wid, ushort rev, uint style, uint format, ref JHTEXTPROG ptextprog, ushort rev2, ref JHBMPINFO pbmpinfo, byte[] pformatstring, byte is1bit);

        [DllImport(zkdll, EntryPoint = "JHCreateQRCodeProg", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHCreateQRCodeProg(IntPtr hdl, ushort wid, ushort rev, uint style, uint format, ref JHTEXTPROG ptextprog, ref JHBMPINFO pbmpinfo, string pformatstring);

        [DllImport(zkdll, EntryPoint = "JHCreateSimpleDigClockProg", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHCreateSimpleDigClockProg(IntPtr hdl, ushort wid, ushort rev, uint style, uint format, uint timeoffset);

        [DllImport(zkdll, EntryPoint = "JHCreateDigClockProg", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHCreateDigClockProg(IntPtr hdl, ushort wid, ushort rev, uint style, uint format, uint timeoffset, string pformatstring);

        [DllImport(zkdll, EntryPoint = "JHCreateComplexDigClockProg", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHCreateComplexDigClockProg(IntPtr hdl, ushort wid, ushort rev, uint style, uint format, uint timeoffset, ref JHTEXTPROG ptextprog, string pformatstring);

        [DllImport(zkdll, EntryPoint = "JHCreateCountdownProg", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHCreateCountdownProg(IntPtr hdl, ushort wid, ushort rev, uint style, uint format, uint timeoffset, uint flag, ref JHSYSTEMTIME ptime, string pformatstring);

        [DllImport(zkdll, EntryPoint = "JHCreateCountupProg", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHCreateCountupProg(IntPtr hdl, ushort wid, ushort rev, uint style, uint format, uint timeoffset, uint flag, ref JHSYSTEMTIME ptime, string pformatstring);

        [DllImport(zkdll, EntryPoint = "JHCreateGridProg", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHCreateGridProg(IntPtr hdl, ushort wid, ushort rev, uint style, uint format, uint flag, string pformatstring);

        [DllImport(zkdll, EntryPoint = "JHGridCreateHandle", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGridCreateHandle(ref IntPtr phdl);

        [DllImport(zkdll, EntryPoint = "JHGridSetRowColCount", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGridSetRowColCount(IntPtr phdl, ushort rowCount, ushort colCount);

        [DllImport(zkdll, EntryPoint = "JHGridSetDefRowHeightColWidth", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGridSetDefRowHeightColWidth(IntPtr phdl, ushort height, ushort width);

        [DllImport(zkdll, EntryPoint = "JHGridSetDefTextFormat", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGridSetDefTextFormat(IntPtr phdl, uint format);

        [DllImport(zkdll, EntryPoint = "JHGridSetRowHeight", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGridSetRowHeight(IntPtr phdl, ushort rowNum, ushort height);

        [DllImport(zkdll, EntryPoint = "JHGridSetColWidth", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGridSetColWidth(IntPtr phdl, ushort colNum, ushort width);

        [DllImport(zkdll, EntryPoint = "JHGridSetCellText", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGridSetCellText(IntPtr phdl, ushort row, ushort col, string ptext);

        [DllImport(zkdll, EntryPoint = "JHGridInsertRowsAt", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGridInsertRowsAt(IntPtr phdl, ushort rowNum, ushort count);

        [DllImport(zkdll, EntryPoint = "JHGridInsertColsAt", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGridInsertColsAt(IntPtr phdl, ushort colNum, ushort count);

        [DllImport(zkdll, EntryPoint = "JHGridRemoveColsAt", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGridRemoveColsAt(IntPtr phdl, ushort colNum, ushort count);

        [DllImport(zkdll, EntryPoint = "JHGridRemoveRowsAt", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGridRemoveRowsAt(IntPtr phdl, ushort rowNum, ushort count);

        [DllImport(zkdll, EntryPoint = "JHGridMergeCells", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGridMergeCells(IntPtr phdl, ushort startRow, ushort startCol, ushort endRow, ushort endCol);

        [DllImport(zkdll, EntryPoint = "JHGridSetCellTextFormat", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGridSetCellTextFormat(IntPtr phdl, ushort row, ushort col, uint format);

        [DllImport(zkdll, EntryPoint = "JHGridSetBorders", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGridSetBorders(IntPtr phdl, ushort row, ushort col, byte border);

        [DllImport(zkdll, EntryPoint = "JHGridGetCellText", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGridGetCellText(IntPtr phdl, ushort row, ushort col, byte[] pdat, ref ushort psize);

        [DllImport(zkdll, EntryPoint = "JHGridGetRowCount", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGridGetRowCount(IntPtr phdl, ref ushort prows);

        [DllImport(zkdll, EntryPoint = "JHGridGetColCount", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGridGetColCount(IntPtr phdl, ref ushort pcols);

        [DllImport(zkdll, EntryPoint = "JHGridGetRowHeight", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGridGetRowHeight(IntPtr phdl, ushort row, ref ushort pheight);

        [DllImport(zkdll, EntryPoint = "JHGridGetColWidth", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGridGetColWidth(IntPtr phdl, ushort col, ref ushort pwidth);

        [DllImport(zkdll, EntryPoint = "JHGridIsMergeCell", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGridIsMergeCell(IntPtr phdl, ushort row, ushort col, ref byte pbMerge);

        [DllImport(zkdll, EntryPoint = "JHGridGetMergeArea", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGridGetMergeArea(IntPtr phdl, ushort row, ushort col, ref ushort pstartRow, ref ushort pstartCol, ref ushort pendRow, ref ushort pendCol);

        [DllImport(zkdll, EntryPoint = "JHGridGetBorders", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGridGetBorders(IntPtr phdl, ushort row, ushort col, ref byte pborders);

        [DllImport(zkdll, EntryPoint = "JHGridGetCellTextFormat", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGridGetCellTextFormat(IntPtr phdl, ushort row, ushort col, ref uint pformat);

        [DllImport(zkdll, EntryPoint = "JHGridDeleteHandle", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGridDeleteHandle(IntPtr phdl);

        [DllImport(zkdll, EntryPoint = "JHGridFormatToHandle", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGridFormatToHandle(IntPtr phdl, string pformatstring);

        [DllImport(zkdll, EntryPoint = "JHGridFormatToString", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGridFormatToString(IntPtr phdl, byte[] pdat, ushort bufsize, ref ushort psize);

        [DllImport(zkdll, EntryPoint = "JHGridSetSlash", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGridSetSlash(IntPtr phdl, ushort row, ushort col, byte bSlash);

        [DllImport(zkdll, EntryPoint = "JHGridGetSlash", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGridGetSlash(IntPtr phdl, ushort row, ushort col, ref byte pbSlash);

        [DllImport(zkdll, EntryPoint = "JHGridSetBackSlash", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGridSetBackSlash(IntPtr phdl, ushort row, ushort col, byte bBackSlash);

        [DllImport(zkdll, EntryPoint = "JHGridGetBackSlash", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGridGetBackSlash(IntPtr phdl, ushort row, ushort col, ref byte pbBackSlash);

        [DllImport(zkdll, EntryPoint = "JHFingerProg", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHFingerProg(IntPtr hdl, ushort wid, ushort option, ref ushort prev, ref ushort ptype, ref uint pstyle, byte[] dat, ref ushort psize);

        [DllImport(zkdll, EntryPoint = "JHDeleteProg", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHDeleteProg(IntPtr hdl, ushort wid, ushort option);

        /***************************************分区操作指令结束*********************************/


        /***************************************事件管理指令开始*********************************/

        [DllImport(zkdll, EntryPoint = "JHEventPoweronConfig", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHEventPoweronConfig(IntPtr hdl, string pformatstring);

        [DllImport(zkdll, EntryPoint = "JHEventPoweronDetail", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHEventPoweronDetail(IntPtr hdl, ref byte pon, string pformatstring);

        [DllImport(zkdll, EntryPoint = "JHEventPoweronSwitch", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHEventPoweronSwitch(IntPtr hdl, byte on);

        [DllImport(zkdll, EntryPoint = "JHEventPoweronDelete", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHEventPoweronDelete(IntPtr hdl);

        [DllImport(zkdll, EntryPoint = "JHEventNocommConfig", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHEventNocommConfig(IntPtr hdl, uint time, string pformatstring);

        [DllImport(zkdll, EntryPoint = "JHEventNocommDetail", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHEventNocommDetail(IntPtr hdl, ref byte pon, ref uint time, string pformatstring);

        [DllImport(zkdll, EntryPoint = "JHEventNocommSwitch", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHEventNocommSwitch(IntPtr hdl, byte on);

        [DllImport(zkdll, EntryPoint = "JHEventNocommDelete", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHEventNocommDelete(IntPtr hdl);

        [DllImport(zkdll, EntryPoint = "JHEventTimerConfig", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHEventTimerConfig(IntPtr hdl, ushort index, byte week, byte hour, byte minute, string pformatstring);

        [DllImport(zkdll, EntryPoint = "JHEventTimerDetail", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHEventTimerDetail(IntPtr hdl, ushort index, ref byte pon, ref byte pweek, ref byte phour, ref byte pminute, string pformatstring);

        [DllImport(zkdll, EntryPoint = "JHEventTimerSwitch", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHEventTimerSwitch(IntPtr hdl, ushort index, byte on);

        [DllImport(zkdll, EntryPoint = "JHEventTimerDelete", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHEventTimerDelete(IntPtr hdl, ushort index);

        [DllImport(zkdll, EntryPoint = "JHEventAutoPowerConfig", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHEventAutoPowerConfig(IntPtr hdl, byte on, byte week, byte on_hour, byte on_minute, byte off_hour, byte off_minute);

        [DllImport(zkdll, EntryPoint = "JHEventAutoPowerDetail", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHEventAutoPowerDetail(IntPtr hdl, ref byte pon, ref byte pweek, ref byte pon_hour, ref byte pon_minute, ref byte poff_hour, ref byte poff_minute);

        /***************************************事件管理指令结束*********************************/



        /***************************************批处理操作指令结束*********************************/

        [DllImport(zkdll, EntryPoint = "JHGetBatchCnt", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGetBatchCnt(IntPtr hdl, ref byte pcnt);

        [DllImport(zkdll, EntryPoint = "JHGetBatchName", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGetBatchName(IntPtr hdl, byte index, string pformatstring);

        [DllImport(zkdll, EntryPoint = "JHPreGetBatch", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHPreGetBatch(IntPtr hdl, ref IntPtr fd, string pformatstring, ref uint readsize);

        [DllImport(zkdll, EntryPoint = "JHReadBatch", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHReadBatch(IntPtr hdl, IntPtr fd, uint roffset, byte[] pdat, ref uint psize);

        [DllImport(zkdll, EntryPoint = "JHFinGetBatch", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHFinGetBatch(IntPtr hdl, IntPtr fd);

        [DllImport(zkdll, EntryPoint = "JHInquireBatch", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHInquireBatch(IntPtr hdl, string pformatstring);

        [DllImport(zkdll, EntryPoint = "JHPreCreateBatch", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHPreCreateBatch(IntPtr hdl, ref IntPtr fd, string pformatstring, uint writesize);

        [DllImport(zkdll, EntryPoint = "JHWriteBatch", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHWriteBatch(IntPtr hdl, IntPtr fd, uint woffset, byte[] pdata, uint size);

        [DllImport(zkdll, EntryPoint = "JHFinCreateBatch", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHFinCreateBatch(IntPtr hdl, IntPtr fd);

        [DllImport(zkdll, EntryPoint = "JHDeleteBatch", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHDeleteBatch(IntPtr hdl, string pformatstring);

        [DllImport(zkdll, EntryPoint = "JHModifyBatchName", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHModifyBatchName(IntPtr hdl, string poformatstring, string pnformatstring);

        [DllImport(zkdll, EntryPoint = "JHExecuteBatch", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHExecuteBatch(IntPtr hdl, string pformatstring);

        [DllImport(zkdll, EntryPoint = "JHCreateBatchFile1", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHCreateBatchFile1(ref IntPtr phdl, string pformatstring);

        [DllImport(zkdll, EntryPoint = "JHCreateBatchFile2", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHCreateBatchFile2(ref IntPtr phdl, string pformatstring, byte[] pdata, uint size);

        [DllImport(zkdll, EntryPoint = "JHDeleteBatchFile", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHDeleteBatchFile(IntPtr phdl);

        [DllImport(zkdll, EntryPoint = "JHGetBatchFileData", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGetBatchFileData(IntPtr phdl, byte[] pdata);

        [DllImport(zkdll, EntryPoint = "JHGetBatchFileSize", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGetBatchFileSize(IntPtr phdl, ref uint pdata);

        [DllImport(zkdll, EntryPoint = "JHGetBatchFileName", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGetBatchFileName(IntPtr phdl, string pformatstring);

        [DllImport(zkdll, EntryPoint = "JHSetBatchFileName", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHSetBatchFileName(IntPtr phdl, string pformatstring);

        [DllImport(zkdll, EntryPoint = "JHSetCurLumIst", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHSetCurLumIst(IntPtr phdl, ushort index, ushort lum);

        [DllImport(zkdll, EntryPoint = "JHSetCurFontIst", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHSetCurFontIst(IntPtr phdl, ushort index, byte fid);

        [DllImport(zkdll, EntryPoint = "JHSetCurPenColorIst", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHSetCurPenColorIst(IntPtr phdl, ushort index, uint color);

        [DllImport(zkdll, EntryPoint = "JHSetCurBrushColorIst", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHSetCurBrushColorIst(IntPtr phdl, ushort index, uint color);

        [DllImport(zkdll, EntryPoint = "JHPowerIst", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHPowerIst(IntPtr phdl, ushort index, byte onoff);

        [DllImport(zkdll, EntryPoint = "JHRestartIst", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHRestartIst(IntPtr phdl, ushort index);

        [DllImport(zkdll, EntryPoint = "JHEraseIst", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHEraseIst(IntPtr phdl, ushort index);

        [DllImport(zkdll, EntryPoint = "JHDrawMultPixelIst", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHDrawMultPixelIst(IntPtr phdl, ushort index, byte[] pdata, ushort poscnt);

        [DllImport(zkdll, EntryPoint = "JHDrawLineIst", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHDrawLineIst(IntPtr phdl, ushort index, short x1, short y1, short x2, short y2);

        [DllImport(zkdll, EntryPoint = "JHFillRectIst", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHFillRectIst(IntPtr phdl, ushort index, short x, short y, ushort width, ushort height);

        [DllImport(zkdll, EntryPoint = "JHDrawTextIst", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHDrawTextIst(IntPtr phdl, ushort index, short x, short y, ushort width, ushort height, uint format, string pformatstring);

        [DllImport(zkdll, EntryPoint = "JHCreateWndIst", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHCreateWndIst(IntPtr phdl, ushort index, ushort wid, ushort option, short x, short y, ushort width, ushort height, uint style, uint userdata);

        [DllImport(zkdll, EntryPoint = "JHChangeWndIst", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHChangeWndIst(IntPtr phdl, ushort index, ushort wid, ushort option, short x, short y, ushort width, ushort height, uint style, uint userdata);

        [DllImport(zkdll, EntryPoint = "JHDeleteWndIst", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHDeleteWndIst(IntPtr phdl, ushort index, ushort wid);

        [DllImport(zkdll, EntryPoint = "JHWndPlayCtrlIst", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHWndPlayCtrlIst(IntPtr phdl, ushort index, ushort wid, byte stat);

        [DllImport(zkdll, EntryPoint = "JHCreateTextProgIst", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHCreateTextProgIst(IntPtr phdl, ushort index, ushort wid, ushort rev, uint style, uint format, ref JHTEXTPROG ptextprog, string pfromatstring);

        [DllImport(zkdll, EntryPoint = "JHCreateSimpleDigClockProgIst", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHCreateSimpleDigClockProgIst(IntPtr phdl, ushort index, ushort wid, ushort rev, uint style, uint format, uint timeoffset);

        [DllImport(zkdll, EntryPoint = "JHCreateDigClockProgIst", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHCreateDigClockProgIst(IntPtr phdl, ushort index, ushort wid, ushort rev, uint style, uint format, uint timeoffset, string pformatstring);

        [DllImport(zkdll, EntryPoint = "JHCreateComplexDigClockProgIst", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHCreateComplexDigClockProgIst(IntPtr phdl, ushort index, ushort wid, ushort rev, uint style, uint format, uint timeoffset, ref JHTEXTPROG ptextprog, string pformatstring);

        [DllImport(zkdll, EntryPoint = "JHCreateGridProgIst", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHCreateGridProgIst(IntPtr phdl, ushort index, ushort wid, ushort rev, uint style, uint format, uint flat, string pformatstring);

        [DllImport(zkdll, EntryPoint = "JHCreateBitmapProgIst", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHCreateBitmapProgIst(IntPtr phdl, ushort index, ushort wid, ushort rev, uint style, uint format, ref JHTEXTPROG ptextprog, ushort rev2, ref JHBMPSRC pbmpsrc);

        [DllImport(zkdll, EntryPoint = "JHCreateMemBitmapProgIst", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHCreateMemBitmapProgIst(IntPtr phdl, ushort index, ushort wid, ushort rev, uint style, uint format, ref JHTEXTPROG ptextprog, ushort rev2, ref JHBMPINFO pbmpinfo, byte[] pdata, byte is1bit);

        [DllImport(zkdll, EntryPoint = "JHCreateQRCodeProgIst", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHCreateQRCodeProgIst(IntPtr phdl, ushort index, ushort wid, ushort rev, uint style, uint format, ref JHTEXTPROG ptextprog, ref JHBMPINFO pbmpinfo, string pformatstring);

        [DllImport(zkdll, EntryPoint = "JHCreateCountDownProgIst", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHCreateCountDownProgIst(IntPtr phdl, ushort index, ushort wid, ushort rev, uint style, uint format, uint timeoffset, uint flag, ref JHSYSTEMTIME ptime, string pformatstring);

        [DllImport(zkdll, EntryPoint = "JHCreateCountUpProgIst", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHCreateCountUpProgIst(IntPtr phdl, ushort index, ushort wid, ushort rev, uint style, uint format, uint timeoffset, uint flag, ref JHSYSTEMTIME ptime, string pformatstring);

        [DllImport(zkdll, EntryPoint = "JHMoveIst", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHMoveIst(IntPtr phdl, ushort oindex, ushort nindex);

        [DllImport(zkdll, EntryPoint = "JHDeleteIst", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHDeleteIst(IntPtr phdl, ushort index);

        [DllImport(zkdll, EntryPoint = "JHGetIstCnt", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGetIstCnt(IntPtr phdl, ref ushort pcnt);

        [DllImport(zkdll, EntryPoint = "JHGetIstCmd", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGetIstCmd(IntPtr phdl, ushort index, ref ushort pcmd);

        [DllImport(zkdll, EntryPoint = "JHGetIstData", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGetIstData(IntPtr phdl, ushort index,byte[] pdata, ref ushort psize);

        [DllImport(zkdll, EntryPoint = "JHSetIstData", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHSetIstData(IntPtr phdl, ushort index, byte[] pdata, ushort psize);

        /***************************************批处理操作指令结束*********************************/



        /***************************************图片管理指令开始*********************************/

        [DllImport(zkdll, EntryPoint = "JHGetBitmapCnt", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGetBitmapCnt(IntPtr hdl, ref ushort pcnt);

        [DllImport(zkdll, EntryPoint = "JHGetBitmapId", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGetBitmapId(IntPtr hdl, ushort index, ref ushort pbid);

        [DllImport(zkdll, EntryPoint = "JHGetBitmapInfo", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGetBitmapInfo(IntPtr hdl, ushort bid, ref BITMAPINFOHEADER pbitmapinfo);

        [DllImport(zkdll, EntryPoint = "JHInquireBitmap", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHInquireBitmap(IntPtr hdl, ushort bid);

        [DllImport(zkdll, EntryPoint = "JHPreCreateBitmap", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHPreCreateBitmap(IntPtr hdl, ref IntPtr pbd, ushort bid, uint writesize);

        [DllImport(zkdll, EntryPoint = "JHWriteBitmap", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHWriteBitmap(IntPtr hdl, IntPtr bd, uint woffset, byte[] pdat, uint size);

        [DllImport(zkdll, EntryPoint = "JHFinCreateBitmap", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHFinCreateBitmap(IntPtr hdl, IntPtr bd);

        [DllImport(zkdll, EntryPoint = "JHDeleteBitmap", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHDeleteBitmap(IntPtr hdl, ushort bid);


        /***************************************图片管理指令结束*********************************/

        /***************************************扩展功能指令结束*********************************/

        [DllImport(zkdll, EntryPoint = "JHSpeechSynthesisStart", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHSpeechSynthesisStart(IntPtr hdl, uint option, ushort num, string pfromatstring);

        [DllImport(zkdll, EntryPoint = "JHSpeechSynthesisStop", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHSpeechSynthesisStop(IntPtr hdl);

        [DllImport(zkdll, EntryPoint = "JHSpeechSynthesisPause", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHSpeechSynthesisPause(IntPtr hdl);

        [DllImport(zkdll, EntryPoint = "JHSpeechSynthesisRestart", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHSpeechSynthesisRestart(IntPtr hdl);

        [DllImport(zkdll, EntryPoint = "JHSpeechSynthesisInquire", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHSpeechSynthesisInquire(IntPtr hdl, ref byte pstat);

        [DllImport(zkdll, EntryPoint = "JHSpeechSynthesisSleep", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHSpeechSynthesisSleep(IntPtr hdl);

        [DllImport(zkdll, EntryPoint = "JHSpeechSynthesisWakeup", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHSpeechSynthesisWakeup(IntPtr hdl);

        [DllImport(zkdll, EntryPoint = "JHSpeechSynthesisSetPara", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHSpeechSynthesisSetPara(IntPtr hdl, ushort para, ushort rev0, ushort rev1, ushort rev2);

        [DllImport(zkdll, EntryPoint = "JHSpeechSynthesisGetVol", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHSpeechSynthesisGetVol(IntPtr hdl, ref byte pvol);

        [DllImport(zkdll, EntryPoint = "JHSpeechSynthesisSetVol", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHSpeechSynthesisSetVol(IntPtr hdl, byte vol);

        [DllImport(zkdll, EntryPoint = "JHSetIOState", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHSetIOState(IntPtr hdl, byte ch, byte state);

        [DllImport(zkdll, EntryPoint = "JHGetIOState", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGetIOState(IntPtr hdl, byte ch, ref byte pstate);

        [DllImport(zkdll, EntryPoint = "JHSetIOMode", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHSetIOMode(IntPtr hdl, byte ch, byte mode, byte save);

        [DllImport(zkdll, EntryPoint = "JHGetIOMode", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int JHGetIOMode(IntPtr hdl, byte ch, ref byte pmode);


        /***************************************扩展功能指令结束*********************************/
    }
}


/* Error */
enum JHZRESULT
{
	JR_OK = (int)0,								    /* (0) Succeeded */
	JR_DISK_ERR,									/* (1) A hard error occurred in the low level disk I/O layer */
	JR_INT_ERR,										/* (2) Assertion failed */
	JR_NOT_READY,									/* (3) The physical drive cannot work */
	JR_NO_FILE,										/* (4) Could not find the file */
	JR_NO_PATH,										/* (5) Could not find the path */
	JR_INVALID_NAME,								/* (6) The path name format is invalid */
	JR_DENIED,										/* (7) Access denied due to prohibited access or directory full */
	JR_EXIST,										/* (8) Access denied due to prohibited access */
	JR_INVALID_OBJECT,								/* (9) The file/directory object is invalid */
	JR_WRITE_PROTECTED,								/* (10) The physical drive is write protected */
	JR_INVALID_DRIVE,								/* (11) The logical drive number is invalid */
	JR_NOT_ENABLED,									/* (12) The volume has no work area */
	JR_NO_FILESYSTEM,								/* (13) There is no valid FAT volume */
	JR_MKFS_ABORTED,								/* (14) The f_mkfs() aborted due to any parameter error */
	JR_TIMEOUT,										/* (15) Could not get a grant to access the volume within defined period */
	JR_LOCKED,										/* (16) The operation is rejected according to the file sharing policy */
	JR_NOT_ENOUGH_CORE,								/* (17) LFN working buffer could not be allocated */
	JR_TOO_MANY_OPEN_FILES,							/* (18) Number of open files > _FS_SHARE */
	JR_INVALID_PARAMETER,							/* (19) Given parameter is invalid */
	IR_INSTR_IGNORE = 30,							/* (30) Ignored instruction */
	JR_UNKNOWN_INSTR = 31,							/* (31) Unknown instruction */
	JR_INSTR_ERR,								    /* (32) Instruction error */
	JR_NOT_ENOUGH_STORAGE,							/* (33) Not enough storage */
	JR_SEQUENCE_ERR,								/* (34) Sequence error */
	JR_FILE_BROKEN,									/* (35) File broken */
	JR_NOT_FONT,									/* (36) Not font file */
	JR_NOT_SUPPORT,									/* (37) Not support function */
	JR_NO_WND,										/* (38) Could not find the wnd */
	JR_NO_PROGRAM,									/* (39) Could not find the program */
	JR_NOMORE_FRAME,								/* (40) No more frame */
	JR_OUT_OF_RANGE,								/* (41) Out of range */
	JR_INVALID_FID,									/* (42) The font id is invalid */
	JR_NO_FONTCODE,									/* (43) Could not find the font code */
	JR_CRC,											/* (44) CRC error */
	JR_INVALID_EVENT,								/* (45) The event is invalid */
	JR_NO_EVENT,									/* (46) The event is not configured */
	JR_INVALID_LEDMOD,								/* (47) LED module config is invalid */
	JR_NO_UPGRADE,									/* (48) Could not find the upgrade info */
	JR_INVALID_UPGRADE,								/* (49) The upgrade info is invalid */
	JR_TRANSFER_ERR,								/* (50) Transfer error */
	JR_PACKET_ERR,									/* (51) Packet error */
	JR_ALREADY_RUNNING,								/* (52) Player already running */
	JR_ALREADY_STOPED,								/* (53) Player already stoped */
	JR_NO_AUTOPOWER,								/* (54) Autopower not  config */
	JR_INVALID_CODE,								/* (55) Invalid font code */
	IR_INVALID_BMPID,								/* (56) The bitmap id is invalid */
	IR_INVALID_BITMAP,								/* (57) The bitmap is invalid */
	IR_SPEECH,										/* (58) Speech error */
	JR_COMM_INVALID_PARAMETER = 256,				/* (256) Given parameter is invalid in communication*/
	JR_COMM_NOT_ENOUGH_CALLOC,						/* (257) Working buffer could not be apply for calloc in communication*/
	JR_COMM_OCUPIED,						        /* (258) Device has been opened in communication*/
	JR_COMM_OPEN_ERR,						        /* (259) Open device error in communication*/
	JR_COMM_CONFIG_ERR,						        /* (260) Configuration informations error in communication*/
	JR_COMM_TRANSFER_ERR,						    /* (261) Transfer error in communication*/
	JR_COMM_TIMEOUT,						        /* (262) Could not get a grant to access the volume within defined period in communication*/
	JR_COMM_MOUNT_ERROR,						    /* (263) Mount error in communication*/
	JR_COMM_UNMOUNT_ERROR,						    /* (264) Unmount error in communication*/
	JR_COMM_LOADDLL_ERROR,						    /* (265) Load dll error in communication*/
	JR_COMM_FUNCENTRY_ERROR,						/* (266) Function entrance not found in communication*/
	JR_COMM_NOT_READY,								/* (267) Transport layer not mounted in communication*/
	JR_API_INVALID_PARAMETER = 512,				    /* (512) Given parameter is invalid in APIs function*/
	JR_API_NOT_ENOUGH_CALLOC,						/* (513) Working buffer could not be apply for calloc in APIs function*/
	JR_API_INVALID_HANDLE,						    /* (514) Given handle is invalid in APIs function*/
	JR_API_PACKET_ERR,						        /* (515) Packet error in APIs function*/
	JR_API_INSTR_ERR,						        /* (516) Instruction error in APIs function*/
	JR_API_NOT_ENOUGH_BUFFER,						/* (517) The provided buffer is too small to storage current data in APIs function*/
	JR_USER = 1024,									/* (1024) User defined, Similar WM_USER*/
}
